-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Report more specific errors for unknown constants #714
Conversation
In case someone encounters some DWARF containing a constant value not known to gimli, let's ensure that the error has the actual constant available in it. These values are not visible in `Error::description` or the various other error-reporting functions which use it, such as the `Display` implementation. I think it would be good to improve that too, but wanted to keep this PR relatively small.
@@ -1048,7 +1048,7 @@ impl<R: Reader> DwarfPackage<R> { | |||
SectionId::DebugMacro | SectionId::DebugMacinfo => { | |||
// These are valid but we can't parse these yet. | |||
} | |||
_ => return Err(Error::UnknownIndexSection), | |||
_ => return Err(Error::UnknownSection(section.section)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fine, I don't think there's a better option, but it feels a bit dirty to add an error variant for a code path that will only occur due to a bug in gimli.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be better to introduce a new enum IndexSectionId
which has only the kinds that are allowed in a UnitIndex
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe. It would avoid this possibility, and most consumers won't be directly using this section id so it won't affect them. Something for another PR though. I'd probably call it DwoSectionId
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Keeping this type distinct from the `SectionId` enum ensures that the compiler will report an error if someone adds incomplete support for new separate-debug sections. As discussed in: gimli-rs#714 (comment) The existing `SectionId::dwo_name` method did not match the list of sections actually supported elsewhere in gimli. I've added the one section ID that was missing (`.debug_macinfo.dwo`), but I have not removed the section IDs which are only present there: `.debug_str.dwo`, `.debug_cu_index`, and `.debug_tu_index`.
In case someone encounters some DWARF containing a constant value not known to gimli, let's ensure that the error has the actual constant available in it.
These values are not visible in
Error::description
or the various other error-reporting functions which use it, such as theDisplay
implementation. I think it would be good to improve that too, but wanted to keep this PR relatively small.